package com.qf.day2;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @date 2022/3/25
 * @desc
 */
@WebServlet(value = {"/second"},loadOnStartup=5,description="演示注解的方式配置servlet")
public class SecondServlet extends HttpServlet {


    @Override
    public void init() throws ServletException {
        System.out.println("我是注解的形式配置的随服务器启动而创建");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("get请求走这里");

        doPost(req,resp);  //把处理请求的代码 写在post 中

        

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("post请求走这里");

        //把处理请求的代码 写在post 中

        //doGet(req,resp);  //把处理请求的代码 写在get 中


        //上面 doGet 里面掉了 doPost 以后咱们把处理请求的代码 就写在doPost 中


        System.out.println("处理请求的代码");

    }
}
